package com.numbfish.ch03_ex02_module_a.config;

import com.numbfish.ch03_ex02_module_a.pojo.PersonA;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(PersonProperties.class)
public class CustomConfigModuleA {
    @Autowired
    private PersonProperties personProperties;

    @Bean
    public PersonA persona() {
        return new PersonA("曹操", 44);
    }

    @Bean
    public PersonA personb() {
        return new PersonA(personProperties.getName(), personProperties.getAge());
    }

}
